﻿using System;
using System.Collections.Generic;

namespace Spencen.Mobile.Markup.Converters
{
    public abstract class Converter<T> : IConverter<T>, IConverter
    {
        #region IConverter<T> Members

        public virtual T ConvertFromString( string input, Type toType )
        {
            throw new NotImplementedException();
        }

        public virtual string ConvertToString( T input )
        {
            return input.ToString();
        }

        public virtual bool CanConvertFromString( string input, Type toType )
        {
            return true;
        }

        #endregion

        #region IConverter Members

        object IConverter.ConvertFromString( string input, Type toType )
        {
            return ConvertFromString( input, toType );
        }

        string IConverter.ConvertToString( object input )
        {
            return ConvertToString( (T)input );
        }

        bool IConverter.CanConvertFromString( string input, Type toType )
        {
            return CanConvertFromString( input, toType );
        }

        #endregion
    }
}
